<template>
<div>
    <h1>code页面</h1> 
    {{a}},{{b}},{{c}}
<router-link to="/Login">跳转Login页面</router-link>
</div>

</template>

<script>
   export default {
        name:  'Code',
        data(){
            return{
               a:'',
               b:'',
               c:'',
               d:''
            }
        },
        components: {},
        beforeRouteEnter(to,from,next){
            console.log('to',to);
            
            console.log('from',from);
            
            next((vm)=>{
             vm.a=1,
             vm.b=3
             if(from.name==='Login'){
                vm.c='Login';
             }
            })

        },
    //     beforeRouteLeave(to, from, next) {  
    //     // 正确的路径比较  
    //     if (to.path === '/Cod') {  
    //         console.log('成功导航到/Code');  
    //         next(); // 允许导航  
    //     } else {  
    //         console.log('阻止导航到其他路径');  
    //         next(false); // 阻止导航  
    //     }  
    // }  
        
   }

   
</script>

<style scoped>

</style>